unsafe-io 0.7.1

Non-owning unsafe I/O
Documentation

Have you ever found yourself writing essentially the same code twice, once for RawFd for Posix-ish platforms and once for RawHandle or RawSocket for Windows platforms? This crate abstracts over those platform differences.

Being non-owning, these handles operate much like raw pointers in Rust. They are considered safe to construct, but unsafe to use in any way that depends on the resource they point to.

This library is meant to be a building block for higher-level libraries, such as the io-streams crate.

Brief Overview

The central type of this library is UnsafeHandle. On Posix-ish platforms it just contains a RawFd. On Windows, it contains an enum of either a RawHandle (for files and pipes), a RawSocket (for sockets), or a stdio handle (for stdin, stdout, stderr), allowing it to abstract over different types of I/O in a similar manner.

UnsafeFile and UnsafeSocket are similar non-owning types, but which only contain one type, instead of an enum, which allow them to be used in contexts that only support one type.

The crate documentation has a complete overview and examples.